package com.infra.micro.oss.domain.repository;

import com.infra.micro.oss.domain.db.entity.BizInfoExample;
import com.infra.micro.oss.domain.db.entity.BizInfoPO;
import com.infra.micro.oss.domain.db.mapper.BizInfoMapper;
import com.infra.micro.oss.domain.db.mapper.ext.BizInfoExtMapper;
import com.infra.micro.oss.model.req.QueryBizInfoReq;
import com.infra.micro.oss.model.vo.BizFileVO;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class BizInfoRepository {
    @Resource
    private BizInfoMapper bizInfoMapper;
    @Resource
    private BizInfoExtMapper bizInfoExtMapper;

    public BizInfoPO queryByBizId(Long bizId) {
        return bizInfoMapper.selectByPrimaryKey(bizId);
    }

    public List<BizFileVO> queryByBizIds(List<Long> bizIds) {
        return bizInfoExtMapper.queryByBizIds(bizIds);
    }

    public List<BizFileVO> queryByCond(QueryBizInfoReq req) {
        return bizInfoExtMapper.queryByCond(req);
    }

    public int deleteByBizId(Long bizId) {
        return bizInfoMapper.deleteByPrimaryKey(bizId);
    }

    public int deleteByBizIds(List<Long> bizId) {
        BizInfoExample example = new BizInfoExample();
        example.createCriteria().andBizIdIn(bizId);
        return bizInfoMapper.deleteByExample(example);
    }

    public int deleteByAppId(String appId) {
        BizInfoExample example = new BizInfoExample();
        example.createCriteria().andAppIdEqualTo(appId);
        return bizInfoMapper.deleteByExample(example);
    }

    public int batchInsert(List<BizFileVO> list) {
        return bizInfoExtMapper.batchInsert(list);
    }

}

